home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / rpm / rpmlib.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-10-22  |  42.7 KB  |  1,258 lines

  1. #ifndef H_RPMLIB
  2. #define    H_RPMLIB
  3.  
  4. /** \ingroup rpmcli rpmrc rpmdep rpmtrans rpmdb lead signature header payload dbi
  5.  * \file lib/rpmlib.h
  6.  *
  7.  * In Memoriam: Steve Taylor <staylor@redhat.com> was here, now he's not.
  8.  *
  9.  */
  10.  
  11. #include "rpmio.h"
  12. #include "rpmmessages.h"
  13. #include "rpmerr.h"
  14. #include "header.h"
  15. #include "popt.h"
  16.  
  17. /**
  18.  * Package read return codes.
  19.  */
  20. typedef    enum rpmRC_e {
  21.     RPMRC_OK        = 0,    /*!< Generic success code */
  22.     RPMRC_NOTFOUND    = 1,    /*!< Generic not found code. */
  23.     RPMRC_FAIL        = 2,    /*!< Generic failure code. */
  24.     RPMRC_NOTTRUSTED    = 3,    /*!< Signature is OK, but key is not trusted. */
  25.     RPMRC_NOKEY        = 4    /*!< Public key is unavailable. */
  26. } rpmRC;
  27.  
  28. /*@-redecl@*/
  29. /*@checked@*/
  30. extern struct MacroContext_s * rpmGlobalMacroContext;
  31.  
  32. /*@checked@*/
  33. extern struct MacroContext_s * rpmCLIMacroContext;
  34.  
  35. /*@unchecked@*/ /*@observer@*/
  36. extern const char * RPMVERSION;
  37.  
  38. /*@unchecked@*/ /*@observer@*/
  39. extern const char * rpmNAME;
  40.  
  41. /*@unchecked@*/ /*@observer@*/
  42. extern const char * rpmEVR;
  43.  
  44. /*@unchecked@*/
  45. extern int rpmFLAGS;
  46. /*@=redecl@*/
  47.  
  48. #ifdef __cplusplus
  49. extern "C" {
  50. #endif
  51.  
  52. /**
  53.  * Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
  54.  * @param p        memory to free
  55.  * @return        NULL always
  56.  */
  57. /*@unused@*/ static inline /*@null@*/
  58. void * _free(/*@only@*/ /*@null@*/ /*@out@*/ const void * p)
  59.     /*@modifies p @*/
  60. {
  61.     if (p != NULL)    free((void *)p);
  62.     return NULL;
  63. }
  64.  
  65. /** \ingroup rpmtrans
  66.  * The RPM Transaction Set.
  67.  * Transaction sets are inherently unordered! RPM may reorder transaction
  68.  * sets to reduce errors. In general, installs/upgrades are done before
  69.  * strict removals, and prerequisite ordering is done on installs/upgrades.
  70.  */
  71. typedef /*@abstract@*/ /*@refcounted@*/ struct rpmts_s * rpmts;
  72.  
  73. /** \ingroup rpmbuild
  74.  */
  75. typedef struct Spec_s * Spec;
  76.  
  77. /** \ingroup rpmtrans
  78.  * An added/available package retrieval key.
  79.  */
  80. typedef /*@abstract@*/ void * alKey;
  81. #define    RPMAL_NOMATCH    ((alKey)-1L)
  82.  
  83. /** \ingroup rpmtrans
  84.  * An added/available package retrieval index.
  85.  */
  86. /*@-mutrep@*/
  87. typedef /*@abstract@*/ int alNum;
  88. /*@=mutrep@*/
  89.  
  90. /** \ingroup rpmtrans
  91.  * Dependency tag sets from a header, so that a header can be discarded early.
  92.  */
  93. typedef /*@abstract@*/ /*@refcounted@*/ struct rpmds_s * rpmds;
  94.  
  95. /** \ingroup rpmtrans
  96.  * File info tag sets from a header, so that a header can be discarded early.
  97.  */
  98. typedef /*@abstract@*/ /*@refcounted@*/ struct rpmfi_s * rpmfi;
  99.  
  100. /** \ingroup rpmtrans
  101.  * An element of a transaction set, i.e. a TR_ADDED or TR_REMOVED package.
  102.  */
  103. typedef /*@abstract@*/ struct rpmte_s * rpmte;
  104.  
  105. /** \ingroup rpmdb
  106.  * Database of headers and tag value indices.
  107.  */
  108. typedef /*@abstract@*/ /*@refcounted@*/ struct rpmdb_s * rpmdb;
  109.  
  110. /** \ingroup rpmdb
  111.  * Database iterator.
  112.  */
  113. typedef /*@abstract@*/ struct _rpmdbMatchIterator * rpmdbMatchIterator;
  114.  
  115. /** \ingroup rpmcli
  116.  * Generalized iterator.
  117.  */
  118. typedef /*@abstract@*/ /*@refcounted@*/ struct rpmgi_s * rpmgi;
  119.  
  120. /** \ingroup header
  121.  * Return name, version, release strings from header.
  122.  * @param h        header
  123.  * @retval *np        name pointer (or NULL)
  124.  * @retval *vp        version pointer (or NULL)
  125.  * @retval *rp        release pointer (or NULL)
  126.  * @return        0 always
  127.  */
  128. int headerNVR(Header h,
  129.         /*@null@*/ /*@out@*/ const char ** np,
  130.         /*@null@*/ /*@out@*/ const char ** vp,
  131.         /*@null@*/ /*@out@*/ const char ** rp)
  132.     /*@modifies *np, *vp, *rp @*/;
  133.  
  134. /** \ingroup header
  135.  * Return name, epoch, version, release, arch strings from header.
  136.  * @param h        header
  137.  * @retval *np        name pointer (or NULL)
  138.  * @retval *ep        epoch pointer (or NULL)
  139.  * @retval *vp        version pointer (or NULL)
  140.  * @retval *rp        release pointer (or NULL)
  141.  * @retval *ap        arch pointer (or NULL)
  142.  * @return        0 always
  143.  */
  144. int headerNEVRA(Header h,
  145.         /*@null@*/ /*@out@*/ const char ** np,
  146.         /*@null@*/ /*@out@*/ /*@unused@*/ const char ** ep,
  147.         /*@null@*/ /*@out@*/ const char ** vp,
  148.         /*@null@*/ /*@out@*/ const char ** rp,
  149.         /*@null@*/ /*@out@*/ const char ** ap)
  150.     /*@modifies *np, *vp, *rp, *ap @*/;
  151.  
  152. /** \ingroup header
  153.  * Translate and merge legacy signature tags into header.
  154.  * @todo Remove headerSort() through headerInitIterator() modifies sig.
  155.  * @param h        header
  156.  * @param sigh        signature header
  157.  */
  158. void headerMergeLegacySigs(Header h, const Header sigh)
  159.     /*@modifies h, sigh @*/;
  160.  
  161. /** \ingroup header
  162.  * Regenerate signature header.
  163.  * @todo Remove headerSort() through headerInitIterator() modifies h.
  164.  * @param h        header
  165.  * @param noArchiveSize    don't copy archive size tag (pre rpm-4.1)
  166.  * @return        regenerated signature header
  167.  */
  168. Header headerRegenSigHeader(const Header h, int noArchiveSize)
  169.     /*@modifies h @*/;
  170.  
  171. /** \ingroup header
  172.  * Retrieve tag info from header.
  173.  * This is a "dressed" entry to headerGetEntry to do:
  174.  *    1) DIRNAME/BASENAME/DIRINDICES -> FILENAMES tag conversions.
  175.  *    2) i18n lookaside (if enabled).
  176.  *
  177.  * @param h        header
  178.  * @param tag        tag
  179.  * @retval type        address of tag value data type
  180.  * @retval p        address of pointer to tag value(s)
  181.  * @retval c        address of number of values
  182.  * @return        0 on success, 1 on bad magic, 2 on error
  183.  */
  184. /*@unused@*/
  185. int rpmHeaderGetEntry(Header h, int_32 tag, /*@out@*/ int_32 *type,
  186.         /*@out@*/ void **p, /*@out@*/ int_32 *c)
  187.     /*@modifies *type, *p, *c @*/;
  188.  
  189. /**
  190.  * Automatically generated table of tag name/value pairs.
  191.  */
  192. /*@-redecl@*/
  193. /*@observer@*/ /*@unchecked@*/
  194. extern const struct headerTagTableEntry_s * rpmTagTable;
  195. /*@=redecl@*/
  196.  
  197. /**
  198.  * Number of entries in rpmTagTable.
  199.  */
  200. /*@-redecl@*/
  201. /*@unchecked@*/
  202. extern const int rpmTagTableSize;
  203. /*@=redecl@*/
  204.  
  205. /**
  206.  * Table of query format extensions.
  207.  * @note Chains to headerDefaultFormats[].
  208.  */
  209. /*@-redecl@*/
  210. /*@unchecked@*/
  211. extern const struct headerSprintfExtension_s rpmHeaderFormats[];
  212. /*@=redecl@*/
  213.  
  214. /**
  215.  * Pseudo-tags used by the rpmdb and rpmgi iterator API's.
  216.  */
  217. #define    RPMDBI_PACKAGES        0    /* Installed package headers. */
  218. #define    RPMDBI_DEPENDS        1    /* Dependency resolution cache. */
  219. #define    RPMDBI_LABEL        2    /* Fingerprint search marker. */
  220. #define    RPMDBI_ADDED        3    /* Added package headers. */
  221. #define    RPMDBI_REMOVED        4    /* Removed package headers. */
  222. #define    RPMDBI_AVAILABLE    5    /* Available package headers. */
  223. #define    RPMDBI_HDLIST        6    /* (rpmgi) Header list. */
  224. #define    RPMDBI_ARGLIST        7    /* (rpmgi) Argument list. */
  225. #define    RPMDBI_FTSWALK        8    /* (rpmgi) File tree  walk. */
  226.  
  227. /**
  228.  * Tags identify data in package headers.
  229.  * @note tags should not have value 0!
  230.  */
  231. /** @todo: Somehow supply type **/
  232. typedef enum rpmTag_e {
  233.  
  234.     RPMTAG_HEADERIMAGE        = HEADER_IMAGE,        /*!< Current image. */
  235.     RPMTAG_HEADERSIGNATURES    = HEADER_SIGNATURES,    /*!< Signatures. */
  236.     RPMTAG_HEADERIMMUTABLE    = HEADER_IMMUTABLE,    /*!< Original image. */
  237. /*@-enummemuse@*/
  238.     RPMTAG_HEADERREGIONS    = HEADER_REGIONS,    /*!< Regions. */
  239.  
  240.     RPMTAG_HEADERI18NTABLE    = HEADER_I18NTABLE, /*!< I18N string locales. */
  241. /*@=enummemuse@*/
  242.  
  243. /* Retrofit (and uniqify) signature tags for use by tagName() and rpmQuery. */
  244. /* the md5 sum was broken *twice* on big endian machines */
  245. /* XXX 2nd underscore prevents tagTable generation */
  246.     RPMTAG_SIG_BASE        = HEADER_SIGBASE,
  247.     RPMTAG_SIGSIZE        = RPMTAG_SIG_BASE+1,    /* i */
  248.     RPMTAG_SIGLEMD5_1        = RPMTAG_SIG_BASE+2,    /*!< internal - obsolete */
  249.     RPMTAG_SIGPGP        = RPMTAG_SIG_BASE+3,    /* x */
  250.     RPMTAG_SIGLEMD5_2        = RPMTAG_SIG_BASE+4,    /*!< internal - obsolete */
  251.     RPMTAG_SIGMD5            = RPMTAG_SIG_BASE+5,    /* x */
  252. #define    RPMTAG_PKGID    RPMTAG_SIGMD5            /* x */
  253.     RPMTAG_SIGGPG            = RPMTAG_SIG_BASE+6,    /* x */
  254.     RPMTAG_SIGPGP5            = RPMTAG_SIG_BASE+7,    /*!< internal - obsolete */
  255.  
  256.     RPMTAG_BADSHA1_1        = RPMTAG_SIG_BASE+8,    /*!< internal - obsolete */
  257.     RPMTAG_BADSHA1_2        = RPMTAG_SIG_BASE+9,    /*!< internal - obsolete */
  258.     RPMTAG_PUBKEYS        = RPMTAG_SIG_BASE+10,    /* s[] */
  259.     RPMTAG_DSAHEADER        = RPMTAG_SIG_BASE+11,    /* x */
  260.     RPMTAG_RSAHEADER        = RPMTAG_SIG_BASE+12,    /* x */
  261.     RPMTAG_SHA1HEADER        = RPMTAG_SIG_BASE+13,    /* s */
  262. #define    RPMTAG_HDRID    RPMTAG_SHA1HEADER    /* s */
  263.  
  264.     RPMTAG_NAME          = 1000,    /* s */
  265. #define    RPMTAG_N    RPMTAG_NAME    /* s */
  266.     RPMTAG_VERSION        = 1001,    /* s */
  267. #define    RPMTAG_V    RPMTAG_VERSION    /* s */
  268.     RPMTAG_RELEASE        = 1002,    /* s */
  269. #define    RPMTAG_R    RPMTAG_RELEASE    /* s */
  270.     RPMTAG_EPOCH           = 1003,    /* i */
  271. #define    RPMTAG_E    RPMTAG_EPOCH    /* i */
  272. #define    RPMTAG_SERIAL    RPMTAG_EPOCH    /* i backward comaptibility */
  273.     RPMTAG_SUMMARY        = 1004,    /* s{} */
  274.     RPMTAG_DESCRIPTION        = 1005,    /* s{} */
  275.     RPMTAG_BUILDTIME        = 1006,    /* i */
  276.     RPMTAG_BUILDHOST        = 1007,    /* s */
  277.     RPMTAG_INSTALLTIME        = 1008,    /* i */
  278.     RPMTAG_SIZE            = 1009,    /* i */
  279.     RPMTAG_DISTRIBUTION        = 1010,    /* s */
  280.     RPMTAG_VENDOR        = 1011,    /* s */
  281.     RPMTAG_GIF            = 1012,    /* x */
  282.     RPMTAG_XPM            = 1013,    /* x */
  283.     RPMTAG_LICENSE        = 1014,    /* s */
  284. #define    RPMTAG_COPYRIGHT RPMTAG_LICENSE    /* s backward comaptibility */
  285.     RPMTAG_PACKAGER        = 1015,    /* s */
  286.     RPMTAG_GROUP        = 1016,    /* s{} */
  287. /*@-enummemuse@*/
  288.     RPMTAG_CHANGELOG        = 1017, /*!< s[] internal */
  289. /*@=enummemuse@*/
  290.     RPMTAG_SOURCE        = 1018,    /* s[] */
  291.     RPMTAG_PATCH        = 1019,    /* s[] */
  292.     RPMTAG_URL            = 1020,    /* s */
  293.     RPMTAG_OS            = 1021,    /* s legacy used int */
  294.     RPMTAG_ARCH            = 1022,    /* s legacy used int */
  295.     RPMTAG_PREIN        = 1023,    /* s */
  296.     RPMTAG_POSTIN        = 1024,    /* s */
  297.     RPMTAG_PREUN        = 1025,    /* s */
  298.     RPMTAG_POSTUN        = 1026,    /* s */
  299.     RPMTAG_OLDFILENAMES        = 1027, /* s[] obsolete */
  300.     RPMTAG_FILESIZES        = 1028,    /* i */
  301.     RPMTAG_FILESTATES        = 1029, /* c */
  302.     RPMTAG_FILEMODES        = 1030,    /* h */
  303.     RPMTAG_FILEUIDS        = 1031, /*!< internal */
  304.     RPMTAG_FILEGIDS        = 1032, /*!< internal */
  305.     RPMTAG_FILERDEVS        = 1033,    /* h */
  306.     RPMTAG_FILEMTIMES        = 1034, /* i */
  307.     RPMTAG_FILEMD5S        = 1035,    /* s[] */
  308.     RPMTAG_FILELINKTOS        = 1036,    /* s[] */
  309.     RPMTAG_FILEFLAGS        = 1037,    /* i */
  310. /*@-enummemuse@*/
  311.     RPMTAG_ROOT            = 1038, /*!< internal - obsolete */
  312. /*@=enummemuse@*/
  313.     RPMTAG_FILEUSERNAME        = 1039,    /* s[] */
  314.     RPMTAG_FILEGROUPNAME    = 1040,    /* s[] */
  315. /*@-enummemuse@*/
  316.     RPMTAG_EXCLUDE        = 1041, /*!< internal - obsolete */
  317.     RPMTAG_EXCLUSIVE        = 1042, /*!< internal - obsolete */
  318. /*@=enummemuse@*/
  319.     RPMTAG_ICON            = 1043,
  320.     RPMTAG_SOURCERPM        = 1044,    /* s */
  321.     RPMTAG_FILEVERIFYFLAGS    = 1045,    /* i */
  322.     RPMTAG_ARCHIVESIZE        = 1046,    /* i */
  323.     RPMTAG_PROVIDENAME        = 1047,    /* s[] */
  324. #define    RPMTAG_PROVIDES RPMTAG_PROVIDENAME    /* s[] */
  325. #define    RPMTAG_P    RPMTAG_PROVIDENAME    /* s[] */
  326.     RPMTAG_REQUIREFLAGS        = 1048,    /* i */
  327.     RPMTAG_REQUIRENAME        = 1049,    /* s[] */
  328. #define    RPMTAG_REQUIRES RPMTAG_REQUIRENAME    /* s[] */
  329. #define    RPMTAG_D    RPMTAG_REQUIRENAME    /* s[] */
  330.     RPMTAG_REQUIREVERSION    = 1050,    /* s[] */
  331.     RPMTAG_NOSOURCE        = 1051, /*!< internal */
  332.     RPMTAG_NOPATCH        = 1052, /*!< internal */
  333.     RPMTAG_CONFLICTFLAGS    = 1053, /* i */
  334.     RPMTAG_CONFLICTNAME        = 1054,    /* s[] */
  335. #define    RPMTAG_CONFLICTS RPMTAG_CONFLICTNAME    /* s[] */
  336. #define    RPMTAG_C    RPMTAG_CONFLICTNAME    /* s[] */
  337.     RPMTAG_CONFLICTVERSION    = 1055,    /* s[] */
  338.     RPMTAG_DEFAULTPREFIX    = 1056, /*!< internal - deprecated */
  339.     RPMTAG_BUILDROOT        = 1057, /*!< internal */
  340.     RPMTAG_INSTALLPREFIX    = 1058, /*!< internal - deprecated */
  341.     RPMTAG_EXCLUDEARCH        = 1059,
  342.     RPMTAG_EXCLUDEOS        = 1060,
  343.     RPMTAG_EXCLUSIVEARCH    = 1061,
  344.     RPMTAG_EXCLUSIVEOS        = 1062,
  345.     RPMTAG_AUTOREQPROV        = 1063, /*!< internal */
  346.     RPMTAG_RPMVERSION        = 1064,    /* s */
  347.     RPMTAG_TRIGGERSCRIPTS    = 1065,    /* s[] */
  348.     RPMTAG_TRIGGERNAME        = 1066,    /* s[] */
  349.     RPMTAG_TRIGGERVERSION    = 1067,    /* s[] */
  350.     RPMTAG_TRIGGERFLAGS        = 1068,    /* i */
  351.     RPMTAG_TRIGGERINDEX        = 1069,    /* i */
  352.     RPMTAG_VERIFYSCRIPT        = 1079,    /* s */
  353.     RPMTAG_CHANGELOGTIME    = 1080,    /* i */
  354.     RPMTAG_CHANGELOGNAME    = 1081,    /* s[] */
  355.     RPMTAG_CHANGELOGTEXT    = 1082,    /* s[] */
  356. /*@-enummemuse@*/
  357.     RPMTAG_BROKENMD5        = 1083, /*!< internal - obsolete */
  358. /*@=enummemuse@*/
  359.     RPMTAG_PREREQ        = 1084, /*!< internal */
  360.     RPMTAG_PREINPROG        = 1085,    /* s */
  361.     RPMTAG_POSTINPROG        = 1086,    /* s */
  362.     RPMTAG_PREUNPROG        = 1087,    /* s */
  363.     RPMTAG_POSTUNPROG        = 1088,    /* s */
  364.     RPMTAG_BUILDARCHS        = 1089,
  365.     RPMTAG_OBSOLETENAME        = 1090,    /* s[] */
  366. #define    RPMTAG_OBSOLETES RPMTAG_OBSOLETENAME    /* s[] */
  367. #define    RPMTAG_O    RPMTAG_OBSOLETENAME    /* s[] */
  368.     RPMTAG_VERIFYSCRIPTPROG    = 1091,    /* s */
  369.     RPMTAG_TRIGGERSCRIPTPROG    = 1092,    /* s */
  370.     RPMTAG_DOCDIR        = 1093, /*!< internal */
  371.     RPMTAG_COOKIE        = 1094,    /* s */
  372.     RPMTAG_FILEDEVICES        = 1095,    /* i */
  373.     RPMTAG_FILEINODES        = 1096,    /* i */
  374.     RPMTAG_FILELANGS        = 1097,    /* s[] */
  375.     RPMTAG_PREFIXES        = 1098,    /* s[] */
  376.     RPMTAG_INSTPREFIXES        = 1099,    /* s[] */
  377.     RPMTAG_TRIGGERIN        = 1100, /*!< internal */
  378.     RPMTAG_TRIGGERUN        = 1101, /*!< internal */
  379.     RPMTAG_TRIGGERPOSTUN    = 1102, /*!< internal */
  380.     RPMTAG_AUTOREQ        = 1103, /*!< internal */
  381.     RPMTAG_AUTOPROV        = 1104, /*!< internal */
  382. /*@-enummemuse@*/
  383.     RPMTAG_CAPABILITY        = 1105, /*!< internal - obsolete */
  384. /*@=enummemuse@*/
  385.     RPMTAG_SOURCEPACKAGE    = 1106, /*!< i src.rpm header marker */
  386. /*@-enummemuse@*/
  387.     RPMTAG_OLDORIGFILENAMES    = 1107, /*!< internal - obsolete */
  388. /*@=enummemuse@*/
  389.     RPMTAG_BUILDPREREQ        = 1108, /*!< internal */
  390.     RPMTAG_BUILDREQUIRES    = 1109, /*!< internal */
  391.     RPMTAG_BUILDCONFLICTS    = 1110, /*!< internal */
  392. /*@-enummemuse@*/
  393.     RPMTAG_BUILDMACROS        = 1111, /*!< internal - unused */
  394. /*@=enummemuse@*/
  395.     RPMTAG_PROVIDEFLAGS        = 1112,    /* i */
  396.     RPMTAG_PROVIDEVERSION    = 1113,    /* s[] */
  397.     RPMTAG_OBSOLETEFLAGS    = 1114,    /* i */
  398.     RPMTAG_OBSOLETEVERSION    = 1115,    /* s[] */
  399.     RPMTAG_DIRINDEXES        = 1116,    /* i */
  400.     RPMTAG_BASENAMES        = 1117,    /* s[] */
  401.     RPMTAG_DIRNAMES        = 1118,    /* s[] */
  402.     RPMTAG_ORIGDIRINDEXES    = 1119, /*!< internal */
  403.     RPMTAG_ORIGBASENAMES    = 1120, /*!< internal */
  404.     RPMTAG_ORIGDIRNAMES        = 1121, /*!< internal */
  405.     RPMTAG_OPTFLAGS        = 1122,    /* s */
  406.     RPMTAG_DISTURL        = 1123,    /* s */
  407.     RPMTAG_PAYLOADFORMAT    = 1124,    /* s */
  408.     RPMTAG_PAYLOADCOMPRESSOR    = 1125,    /* s */
  409.     RPMTAG_PAYLOADFLAGS        = 1126,    /* s */
  410.     RPMTAG_INSTALLCOLOR        = 1127, /*!< i transaction color when installed */
  411.     RPMTAG_INSTALLTID        = 1128,    /* i */
  412.     RPMTAG_REMOVETID        = 1129,    /* i */
  413. /*@-enummemuse@*/
  414.     RPMTAG_SHA1RHN        = 1130, /*!< internal - obsolete */
  415. /*@=enummemuse@*/
  416.     RPMTAG_RHNPLATFORM        = 1131,    /* s */
  417.     RPMTAG_PLATFORM        = 1132,    /* s */
  418.     RPMTAG_PATCHESNAME        = 1133, /*!< placeholder (SuSE) */
  419.     RPMTAG_PATCHESFLAGS        = 1134, /*!< placeholder (SuSE) */
  420.     RPMTAG_PATCHESVERSION    = 1135, /*!< placeholder (SuSE) */
  421.     RPMTAG_CACHECTIME        = 1136,    /* i */
  422.     RPMTAG_CACHEPKGPATH        = 1137,    /* s */
  423.     RPMTAG_CACHEPKGSIZE        = 1138,    /* i */
  424.     RPMTAG_CACHEPKGMTIME    = 1139,    /* i */
  425.     RPMTAG_FILECOLORS        = 1140,    /* i */
  426.     RPMTAG_FILECLASS        = 1141,    /* i */
  427.     RPMTAG_CLASSDICT        = 1142,    /* s[] */
  428.     RPMTAG_FILEDEPENDSX        = 1143,    /* i */
  429.     RPMTAG_FILEDEPENDSN        = 1144,    /* i */
  430.     RPMTAG_DEPENDSDICT        = 1145,    /* i */
  431.     RPMTAG_SOURCEPKGID        = 1146,    /* x */
  432.     RPMTAG_FILECONTEXTS        = 1147,    /* s[] */
  433.     RPMTAG_FSCONTEXTS        = 1148,    /*!< s[] extension */
  434.     RPMTAG_RECONTEXTS        = 1149,    /*!< s[] extension */
  435.     RPMTAG_POLICIES        = 1150,    /*!< s[] selinux *.te policy file. */
  436.     RPMTAG_PRETRANS        = 1151,    /* s */
  437.     RPMTAG_POSTTRANS        = 1152,    /* s */
  438.     RPMTAG_PRETRANSPROG        = 1153,    /* s */
  439.     RPMTAG_POSTTRANSPROG    = 1154,    /* s */
  440.     RPMTAG_DISTTAG        = 1155,    /* s */
  441.     RPMTAG_SUGGESTSNAME        = 1156,    /* s[] extension placeholder */
  442.     RPMTAG_SUGGESTSVERSION    = 1157,    /* s[] extension placeholder */
  443.     RPMTAG_SUGGESTSFLAGS    = 1158,    /* i   extension placeholder */
  444.     RPMTAG_ENHANCESNAME        = 1159,    /* s[] extension placeholder */
  445.     RPMTAG_ENHANCESVERSION    = 1160,    /* s[] extension placeholder */
  446.     RPMTAG_ENHANCESFLAGS    = 1161,    /* i   extension placeholder */
  447.     RPMTAG_PRIORITY        = 1162, /* i   extension placeholder */
  448.     RPMTAG_CVSID        = 1163, /* s */
  449. #define    RPMTAG_SVNID    RPMTAG_CVSID    /* s */
  450.     RPMTAG_TRIGGERPREIN        = 1171, /*!< internal */
  451.  
  452. /*@-enummemuse@*/
  453.     RPMTAG_FIRSTFREE_TAG    /*!< internal */
  454. /*@=enummemuse@*/
  455. } rpmTag;
  456.  
  457. #define    RPMTAG_EXTERNAL_TAG        1000000
  458.  
  459. /**
  460.  * File States (when installed).
  461.  */
  462. typedef enum rpmfileState_e {
  463.     RPMFILE_STATE_NORMAL     = 0,
  464.     RPMFILE_STATE_REPLACED     = 1,
  465.     RPMFILE_STATE_NOTINSTALLED    = 2,
  466.     RPMFILE_STATE_NETSHARED    = 3,
  467.     RPMFILE_STATE_WRONGCOLOR    = 4
  468. } rpmfileState;
  469. #define    RPMFILE_STATE_MISSING    -1    /* XXX used for unavailable data */
  470.  
  471. /**
  472.  * File Attributes.
  473.  */
  474. typedef    enum rpmfileAttrs_e {
  475. /*@-enummemuse@*/
  476.     RPMFILE_NONE    = 0,
  477. /*@=enummemuse@*/
  478.     RPMFILE_CONFIG    = (1 <<  0),    /*!< from %%config */
  479.     RPMFILE_DOC        = (1 <<  1),    /*!< from %%doc */
  480.     RPMFILE_ICON    = (1 <<  2),    /*!< from %%donotuse. */
  481.     RPMFILE_MISSINGOK    = (1 <<  3),    /*!< from %%config(missingok) */
  482.     RPMFILE_NOREPLACE    = (1 <<  4),    /*!< from %%config(noreplace) */
  483.     RPMFILE_SPECFILE    = (1 <<  5),    /*!< @todo (unnecessary) marks 1st file in srpm. */
  484.     RPMFILE_GHOST    = (1 <<  6),    /*!< from %%ghost */
  485.     RPMFILE_LICENSE    = (1 <<  7),    /*!< from %%license */
  486.     RPMFILE_README    = (1 <<  8),    /*!< from %%readme */
  487.     RPMFILE_EXCLUDE    = (1 <<  9),    /*!< from %%exclude, internal */
  488.     RPMFILE_UNPATCHED    = (1 << 10),    /*!< placeholder (SuSE) */
  489.     RPMFILE_PUBKEY    = (1 << 11),    /*!< from %%pubkey */
  490.     RPMFILE_POLICY    = (1 << 12)    /*!< from %%policy */
  491. } rpmfileAttrs;
  492.  
  493. #define    RPMFILE_ALL    ~(RPMFILE_NONE)
  494.  
  495. /**
  496.  * Dependency Attributes.
  497.  */
  498. typedef    enum rpmsenseFlags_e {
  499.     RPMSENSE_ANY    = 0,
  500. /*@-enummemuse@*/
  501.     RPMSENSE_SERIAL    = (1 << 0),    /*!< @todo Legacy. */
  502. /*@=enummemuse@*/
  503.     RPMSENSE_LESS    = (1 << 1),
  504.     RPMSENSE_GREATER    = (1 << 2),
  505.     RPMSENSE_EQUAL    = (1 << 3),
  506.     RPMSENSE_PROVIDES    = (1 << 4), /* only used internally by builds */
  507.     RPMSENSE_CONFLICTS    = (1 << 5), /* only used internally by builds */
  508.     /* bit 6 used to be RPMSENSE_PREREQ */
  509. #define    RPMSENSE_PREREQ    RPMSENSE_ANY
  510.     RPMSENSE_OBSOLETES    = (1 << 7), /* only used internally by builds */
  511.     RPMSENSE_INTERP    = (1 << 8),    /*!< Interpreter used by scriptlet. */
  512.     RPMSENSE_SCRIPT_PRE    = ((1 << 9)|RPMSENSE_PREREQ), /*!< %pre dependency. */
  513.     RPMSENSE_SCRIPT_POST = ((1 << 10)|RPMSENSE_PREREQ), /*!< %post dependency. */
  514.     RPMSENSE_SCRIPT_PREUN = ((1 << 11)|RPMSENSE_PREREQ), /*!< %preun dependency. */
  515.     RPMSENSE_SCRIPT_POSTUN = ((1 << 12)|RPMSENSE_PREREQ), /*!< %postun dependency. */
  516.     RPMSENSE_SCRIPT_VERIFY = (1 << 13),    /*!< %verify dependency. */
  517.     RPMSENSE_FIND_REQUIRES = (1 << 14), /*!< find-requires generated dependency. */
  518.     RPMSENSE_FIND_PROVIDES = (1 << 15), /*!< find-provides generated dependency. */
  519.  
  520.     RPMSENSE_TRIGGERIN    = (1 << 16),    /*!< %triggerin dependency. */
  521.     RPMSENSE_TRIGGERUN    = (1 << 17),    /*!< %triggerun dependency. */
  522.     RPMSENSE_TRIGGERPOSTUN = (1 << 18),    /*!< %triggerpostun dependency. */
  523.     RPMSENSE_MISSINGOK    = (1 << 19),    /*!< suggests/enhances hint. */
  524.     RPMSENSE_SCRIPT_PREP = (1 << 20),    /*!< %prep build dependency. */
  525.     RPMSENSE_SCRIPT_BUILD = (1 << 21),    /*!< %build build dependency. */
  526.     RPMSENSE_SCRIPT_INSTALL = (1 << 22),/*!< %install build dependency. */
  527.     RPMSENSE_SCRIPT_CLEAN = (1 << 23),    /*!< %clean build dependency. */
  528.     RPMSENSE_RPMLIB = ((1 << 24) | RPMSENSE_PREREQ), /*!< rpmlib(feature) dependency. */
  529. /*@-enummemuse@*/
  530.     RPMSENSE_TRIGGERPREIN = (1 << 25),    /*!< @todo Implement %triggerprein. */
  531. /*@=enummemuse@*/
  532.     RPMSENSE_KEYRING    = (1 << 26),
  533.     RPMSENSE_PATCHES    = (1 << 27),
  534.     RPMSENSE_CONFIG    = (1 << 28)
  535. } rpmsenseFlags;
  536.  
  537. #define    RPMSENSE_SENSEMASK    15     /* Mask to get senses, ie serial, */
  538.                                          /* less, greater, equal.          */
  539.  
  540. #define    RPMSENSE_TRIGGER    \
  541.     (RPMSENSE_TRIGGERPREIN | RPMSENSE_TRIGGERIN | RPMSENSE_TRIGGERUN | RPMSENSE_TRIGGERPOSTUN)
  542.  
  543. #define    _ALL_REQUIRES_MASK    (\
  544.     RPMSENSE_INTERP | \
  545.     RPMSENSE_SCRIPT_PRE | \
  546.     RPMSENSE_SCRIPT_POST | \
  547.     RPMSENSE_SCRIPT_PREUN | \
  548.     RPMSENSE_SCRIPT_POSTUN | \
  549.     RPMSENSE_SCRIPT_VERIFY | \
  550.     RPMSENSE_FIND_REQUIRES | \
  551.     RPMSENSE_SCRIPT_PREP | \
  552.     RPMSENSE_SCRIPT_BUILD | \
  553.     RPMSENSE_SCRIPT_INSTALL | \
  554.     RPMSENSE_SCRIPT_CLEAN | \
  555.     RPMSENSE_RPMLIB | \
  556.     RPMSENSE_KEYRING )
  557.  
  558. #define    _notpre(_x)        ((_x) & ~RPMSENSE_PREREQ)
  559. #define    _INSTALL_ONLY_MASK \
  560.     _notpre(RPMSENSE_SCRIPT_PRE|RPMSENSE_SCRIPT_POST|RPMSENSE_RPMLIB|RPMSENSE_KEYRING)
  561. #define    _ERASE_ONLY_MASK  \
  562.     _notpre(RPMSENSE_SCRIPT_PREUN|RPMSENSE_SCRIPT_POSTUN)
  563.  
  564. #define    isLegacyPreReq(_x)  (((_x) & _ALL_REQUIRES_MASK) == RPMSENSE_PREREQ)
  565. #define    isInstallPreReq(_x)    ((_x) & _INSTALL_ONLY_MASK)
  566. #define    isErasePreReq(_x)    ((_x) & _ERASE_ONLY_MASK)
  567.  
  568. /* ==================================================================== */
  569. /** \name RPMRC */
  570. /*@{*/
  571.  
  572. /* Stuff for maintaining "variables" like SOURCEDIR, BUILDDIR, etc */
  573. #define    RPMVAR_OPTFLAGS            3
  574. #define    RPMVAR_PROVIDES            38
  575. #define    RPMVAR_INCLUDE            43
  576. #define    RPMVAR_MACROFILES        49
  577.  
  578. #define    RPMVAR_NUM            55    /* number of RPMVAR entries */
  579.  
  580. /** \ingroup rpmrc
  581.  * Return value of an rpmrc variable.
  582.  * @deprecated Use rpmExpand() with appropriate macro expression.
  583.  * @todo Eliminate from API.
  584.  */
  585. /*@-redecl@*/
  586. /*@observer@*/ /*@null@*/ extern const char * rpmGetVar(int var)
  587.     /*@*/;
  588. /*@=redecl@*/
  589.  
  590. /** \ingroup rpmrc
  591.  * Set value of an rpmrc variable.
  592.  * @deprecated Use rpmDefineMacro() to change appropriate macro instead.
  593.  * @todo Eliminate from API.
  594.  */
  595. void rpmSetVar(int var, const char * val)
  596.     /*@globals internalState@*/
  597.     /*@modifies internalState @*/;
  598.  
  599. /** \ingroup rpmrc
  600.  * Build and install arch/os table identifiers.
  601.  * @todo Eliminate from API.
  602.  */
  603. enum rpm_machtable_e {
  604.     RPM_MACHTABLE_INSTARCH    = 0,    /*!< Install platform architecture. */
  605.     RPM_MACHTABLE_INSTOS    = 1,    /*!< Install platform operating system. */
  606.     RPM_MACHTABLE_BUILDARCH    = 2,    /*!< Build platform architecture. */
  607.     RPM_MACHTABLE_BUILDOS    = 3    /*!< Build platform operating system. */
  608. };
  609. #define    RPM_MACHTABLE_COUNT    4    /*!< No. of arch/os tables. */
  610.  
  611. /** \ingroup rpmrc
  612.  * Read macro configuration file(s) for a target.
  613.  * @param file        colon separated files to read (NULL uses default)
  614.  * @param target    target platform (NULL uses default)
  615.  * @return        0 on success, -1 on error
  616.  */
  617. int rpmReadConfigFiles(/*@null@*/ const char * file,
  618.         /*@null@*/ const char * target)
  619.     /*@globals rpmGlobalMacroContext, rpmCLIMacroContext, h_errno,
  620.         fileSystem, internalState @*/
  621.     /*@modifies rpmGlobalMacroContext, rpmCLIMacroContext,
  622.         fileSystem, internalState @*/;
  623.  
  624. /** \ingroup rpmrc
  625.  * Return current arch name and/or number.
  626.  * @todo Generalize to extract arch component from target_platform macro.
  627.  * @retval name        address of arch name (or NULL)
  628.  * @retval num        address of arch number (or NULL)
  629.  */
  630. void rpmGetArchInfo( /*@null@*/ /*@out@*/ const char ** name,
  631.         /*@null@*/ /*@out@*/ int * num)
  632.     /*@modifies *name, *num @*/;
  633.  
  634. /** \ingroup rpmrc
  635.  * Return current os name and/or number.
  636.  * @todo Generalize to extract os component from target_platform macro.
  637.  * @retval name        address of os name (or NULL)
  638.  * @retval num        address of os number (or NULL)
  639.  */
  640. void rpmGetOsInfo( /*@null@*/ /*@out@*/ const char ** name,
  641.         /*@null@*/ /*@out@*/ int * num)
  642.     /*@modifies *name, *num @*/;
  643.  
  644. /** \ingroup rpmrc
  645.  * Return arch/os score of a name.
  646.  * An arch/os score measures the "nearness" of a name to the currently
  647.  * running (or defined) platform arch/os. For example, the score of arch
  648.  * "i586" on an i686 platform is (usually) 2. The arch/os score is used
  649.  * to select one of several otherwise identical packages using the arch/os
  650.  * tags from the header as hints of the intended platform for the package.
  651.  * @todo Rewrite to use RE's against config.guess target platform output.
  652.  *
  653.  * @param type        any of the RPM_MACHTABLE_* constants
  654.  * @param name        name
  655.  * @return        arch score (0 is no match, lower is preferred)
  656.  */
  657. int rpmMachineScore(int type, const char * name)
  658.     /*@*/;
  659.  
  660. /** \ingroup rpmrc
  661.  * Display current rpmrc (and macro) configuration.
  662.  * @param fp        output file handle
  663.  * @return        0 always
  664.  */
  665. int rpmShowRC(FILE * fp)
  666.     /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
  667.     /*@modifies *fp, rpmGlobalMacroContext, fileSystem, internalState  @*/;
  668.  
  669. /** \ingroup rpmrc
  670.  * @deprecated Use addMacro to set _target_* macros.
  671.  * @todo Eliminate from API.
  672.  # @note Only used by build code.
  673.  * @param archTable
  674.  * @param osTable
  675.  */
  676. void rpmSetTables(int archTable, int osTable)
  677.     /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
  678.     /*@modifies rpmGlobalMacroContext, fileSystem, internalState @*/;
  679.  
  680. /** \ingroup rpmrc
  681.  * Set current arch/os names.
  682.  * NULL as argument is set to the default value (munged uname())
  683.  * pushed through a translation table (if appropriate).
  684.  * @deprecated Use addMacro to set _target_* macros.
  685.  * @todo Eliminate from API.
  686.  *
  687.  * @param arch        arch name (or NULL)
  688.  * @param os        os name (or NULL)
  689.  */
  690. void rpmSetMachine(/*@null@*/ const char * arch, /*@null@*/ const char * os)
  691.     /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
  692.     /*@modifies rpmGlobalMacroContext, fileSystem, internalState @*/;
  693.  
  694. /** \ingroup rpmrc
  695.  * Return current arch/os names.
  696.  * @deprecated Use rpmExpand on _target_* macros.
  697.  * @todo Eliminate from API.
  698.  *
  699.  * @retval arch        address of arch name (or NULL)
  700.  * @retval os        address of os name (or NULL)
  701.  */
  702. /*@unused@*/
  703. void rpmGetMachine( /*@null@*/ /*@out@*/ const char **arch,
  704.         /*@null@*/ /*@out@*/ const char **os)
  705.     /*@modifies *arch, *os @*/;
  706.  
  707. /** \ingroup rpmrc
  708.  * Destroy rpmrc arch/os compatibility tables.
  709.  * @todo Eliminate from API.
  710.  */
  711. void rpmFreeRpmrc(void)
  712.     /*@globals internalState @*/
  713.     /*@modifies internalState @*/;
  714.  
  715. /*@}*/
  716. /* ==================================================================== */
  717. /** \name RPMTS */
  718. /*@{*/
  719. /**
  720.  * Prototype for headerFreeData() vector.
  721.  *
  722.  * @param data        address of data (or NULL)
  723.  * @param type        type of data (or -1 to force free)
  724.  * @return        NULL always
  725.  */
  726. typedef /*@null@*/
  727.     void * (*HFD_t) (/*@only@*/ /*@null@*/ const void * data, rpmTagType type)
  728.     /*@modifies data @*/;
  729.  
  730. /**
  731.  * Prototype for headerGetEntry() vector.
  732.  *
  733.  * Will never return RPM_I18NSTRING_TYPE! RPM_STRING_TYPE elements with
  734.  * RPM_I18NSTRING_TYPE equivalent entries are translated (if HEADER_I18NTABLE
  735.  * entry is present).
  736.  *
  737.  * @param h        header
  738.  * @param tag        tag
  739.  * @retval type        address of tag value data type (or NULL)
  740.  * @retval p        address of pointer to tag value(s) (or NULL)
  741.  * @retval c        address of number of values (or NULL)
  742.  * @return        1 on success, 0 on failure
  743.  */
  744. typedef int (*HGE_t) (Header h, rpmTag tag,
  745.             /*@null@*/ /*@out@*/ rpmTagType * type,
  746.             /*@null@*/ /*@out@*/ void ** p,
  747.             /*@null@*/ /*@out@*/ int_32 * c)
  748.     /*@modifies *type, *p, *c @*/;
  749.  
  750. /**
  751.  * Prototype for headerAddEntry() vector.
  752.  *
  753.  * Duplicate tags are okay, but only defined for iteration (with the
  754.  * exceptions noted below). While you are allowed to add i18n string
  755.  * arrays through this function, you probably don't mean to. See
  756.  * headerAddI18NString() instead.
  757.  *
  758.  * @param h             header
  759.  * @param tag           tag
  760.  * @param type          tag value data type
  761.  * @param p             pointer to tag value(s)
  762.  * @param c             number of values
  763.  * @return              1 on success, 0 on failure
  764.  */
  765. typedef int (*HAE_t) (Header h, rpmTag tag, rpmTagType type,
  766.             const void * p, int_32 c)
  767.     /*@modifies h @*/;
  768.  
  769. /**
  770.  * Prototype for headerModifyEntry() vector.
  771.  * If there are multiple entries with this tag, the first one gets replaced.
  772.  *
  773.  * @param h        header
  774.  * @param tag        tag
  775.  * @param type        tag value data type
  776.  * @param p        pointer to tag value(s)
  777.  * @param c        number of values
  778.  * @return        1 on success, 0 on failure
  779.  */
  780. typedef int (*HME_t) (Header h, rpmTag tag, rpmTagType type,
  781.             const void * p, int_32 c)
  782.     /*@modifies h @*/;
  783.  
  784. /**
  785.  * Prototype for headerRemoveEntry() vector.
  786.  * Delete tag in header.
  787.  * Removes all entries of type tag from the header, returns 1 if none were
  788.  * found.
  789.  *
  790.  * @param h        header
  791.  * @param tag        tag
  792.  * @return        0 on success, 1 on failure (INCONSISTENT)
  793.  */
  794. typedef int (*HRE_t) (Header h, int_32 tag)
  795.     /*@modifies h @*/;
  796.  
  797. /**
  798.  * @todo Generalize filter mechanism.
  799.  */
  800. typedef enum rpmprobFilterFlags_e {
  801.     RPMPROB_FILTER_NONE        = 0,
  802.     RPMPROB_FILTER_IGNOREOS    = (1 << 0),    /*!< from --ignoreos */
  803.     RPMPROB_FILTER_IGNOREARCH    = (1 << 1),    /*!< from --ignorearch */
  804.     RPMPROB_FILTER_REPLACEPKG    = (1 << 2),    /*!< from --replacepkgs */
  805.     RPMPROB_FILTER_FORCERELOCATE= (1 << 3),    /*!< from --badreloc */
  806.     RPMPROB_FILTER_REPLACENEWFILES= (1 << 4),    /*!< from --replacefiles */
  807.     RPMPROB_FILTER_REPLACEOLDFILES= (1 << 5),    /*!< from --replacefiles */
  808.     RPMPROB_FILTER_OLDPACKAGE    = (1 << 6),    /*!< from --oldpackage */
  809.     RPMPROB_FILTER_DISKSPACE    = (1 << 7),    /*!< from --ignoresize */
  810.     RPMPROB_FILTER_DISKNODES    = (1 << 8)    /*!< from --ignoresize */
  811. } rpmprobFilterFlags;
  812.  
  813. /**
  814.  * We pass these around as an array with a sentinel.
  815.  */
  816. typedef struct rpmRelocation_s {
  817. /*@only@*/ /*@null@*/
  818.     const char * oldPath;    /*!< NULL here evals to RPMTAG_DEFAULTPREFIX, */
  819. /*@only@*/ /*@null@*/
  820.     const char * newPath;    /*!< NULL means to omit the file completely! */
  821. } rpmRelocation;
  822.  
  823. /**
  824.  * Compare headers to determine which header is "newer".
  825.  * @param first        1st header
  826.  * @param second    2nd header
  827.  * @return        result of comparison
  828.  */
  829. int rpmVersionCompare(Header first, Header second)
  830.     /*@*/;
  831.  
  832. /**
  833.  * File disposition(s) during package install/erase transaction.
  834.  */
  835. typedef enum fileAction_e {
  836.     FA_UNKNOWN = 0,    /*!< initial action for file ... */
  837.     FA_CREATE,        /*!< ... copy in from payload. */
  838.     FA_COPYIN,        /*!< ... copy in from payload. */
  839.     FA_COPYOUT,        /*!< ... copy out to payload. */
  840.     FA_BACKUP,        /*!< ... renamed with ".rpmorig" extension. */
  841.     FA_SAVE,        /*!< ... renamed with ".rpmsave" extension. */
  842.     FA_SKIP,         /*!< ... already replaced, don't remove. */
  843.     FA_ALTNAME,        /*!< ... create with ".rpmnew" extension. */
  844.     FA_ERASE,        /*!< ... to be removed. */
  845.     FA_SKIPNSTATE,    /*!< ... untouched, state "not installed". */
  846.     FA_SKIPNETSHARED,    /*!< ... untouched, state "netshared". */
  847.     FA_SKIPCOLOR    /*!< ... untouched, state "wrong color". */
  848. } fileAction;
  849.  
  850. #define XFA_SKIPPING(_a)    \
  851.     ((_a) == FA_SKIP || (_a) == FA_SKIPNSTATE || (_a) == FA_SKIPNETSHARED || (_a) == FA_SKIPCOLOR)
  852.  
  853. /**
  854.  * File types.
  855.  * These are the file types used internally by rpm. The file
  856.  * type is determined by applying stat(2) macros like S_ISDIR to
  857.  * the file mode tag from a header. The values are arbitrary,
  858.  * but are identical to the linux stat(2) file types.
  859.  */
  860. typedef enum fileTypes_e {
  861.     PIPE    =  1,    /*!< pipe/fifo */
  862.     CDEV    =  2,    /*!< character device */
  863.     XDIR    =  4,    /*!< directory */
  864.     BDEV    =  6,    /*!< block device */
  865.     REG        =  8,    /*!< regular file */
  866.     LINK    = 10,    /*!< hard link */
  867.     SOCK    = 12    /*!< socket */
  868. } fileTypes;
  869.  
  870. /** \ingroup payload
  871.  * Iterator across package file info, forward on install, backward on erase.
  872.  */
  873. typedef /*@abstract@*/ struct fsmIterator_s * FSMI_t;
  874.  
  875. /** \ingroup payload
  876.  * File state machine data.
  877.  */
  878. typedef /*@abstract@*/ struct fsm_s * FSM_t;
  879.  
  880. /** \ingroup rpmtrans
  881.  * Package state machine data.
  882.  */
  883. typedef /*@abstract@*/ /*@refcounted@*/ struct rpmpsm_s * rpmpsm;
  884.  
  885. /**
  886.  * Perform simple sanity and range checks on header tag(s).
  887.  * @param il        no. of tags in header
  888.  * @param dl        no. of bytes in header data.
  889.  * @param pev        1st element in tag array, big-endian
  890.  * @param iv        failing (or last) tag element, host-endian
  891.  * @param negate    negative offset expected?
  892.  * @return        -1 on success, otherwise failing tag element index
  893.  */
  894. int headerVerifyInfo(int il, int dl, const void * pev, void * iv, int negate)
  895.     /*@modifies *iv @*/;
  896.  
  897. /**
  898.  * Check for supported payload format in header.
  899.  * @param h        header to check
  900.  * @return        RPMRC_OK if supported, RPMRC_FAIL otherwise
  901.  */
  902. rpmRC headerCheckPayloadFormat(Header h);
  903.  
  904. /** 
  905.  * Check header consistency, performing headerGetEntry() the hard way.
  906.  *  
  907.  * Sanity checks on the header are performed while looking for a
  908.  * header-only digest or signature to verify the blob. If found,
  909.  * the digest or signature is verified.
  910.  *
  911.  * @param ts        transaction set
  912.  * @param uh        unloaded header blob
  913.  * @param uc        no. of bytes in blob (or 0 to disable)
  914.  * @retval *msg        verification error message (or NULL)
  915.  * @return        RPMRC_OK on success
  916.  */
  917. rpmRC headerCheck(rpmts ts, const void * uh, size_t uc,
  918.         /*@out@*/ /*@null@*/ const char ** msg)
  919.     /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
  920.     /*@modifies ts, *msg, rpmGlobalMacroContext,
  921.         fileSystem, internalState @*/;
  922.  
  923. /** 
  924.  * Return checked and loaded header.
  925.  * @param ts        transaction set
  926.  * @param fd        file handle
  927.  * @retval hdrp        address of header (or NULL)
  928.  * @retval *msg        verification error message (or NULL)
  929.  * @return        RPMRC_OK on success
  930.  */
  931. rpmRC rpmReadHeader(rpmts ts, FD_t fd, /*@out@*/ Header *hdrp,
  932.         /*@out@*/ /*@null@*/ const char ** msg)
  933.         /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
  934.         /*@modifies ts, *hdrp, *msg, rpmGlobalMacroContext,
  935.                 fileSystem, internalState @*/;
  936.  
  937. /**
  938.  * Return package header from file handle, verifying digests/signatures.
  939.  * @param ts        transaction set
  940.  * @param fd        file handle
  941.  * @param fn        file name
  942.  * @retval hdrp        address of header (or NULL)
  943.  * @return        RPMRC_OK on success
  944.  */
  945. rpmRC rpmReadPackageFile(rpmts ts, FD_t fd,
  946.         const char * fn, /*@null@*/ /*@out@*/ Header * hdrp)
  947.     /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
  948.     /*@modifies ts, fd, *hdrp, rpmGlobalMacroContext,
  949.         fileSystem, internalState @*/;
  950.  
  951. /**
  952.  * Install source package.
  953.  * @param ts        transaction set
  954.  * @param fd        file handle
  955.  * @retval specFilePtr    address of spec file name (or NULL)
  956.  * @retval cookie    address of cookie pointer (or NULL)
  957.  * @return        rpmRC return code
  958.  */
  959. rpmRC rpmInstallSourcePackage(rpmts ts, FD_t fd,
  960.             /*@null@*/ /*@out@*/ const char ** specFilePtr,
  961.             /*@null@*/ /*@out@*/ const char ** cookie)
  962.     /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
  963.     /*@modifies ts, fd, *specFilePtr, *cookie, rpmGlobalMacroContext,
  964.         fileSystem, internalState @*/;
  965.  
  966. /** \ingroup rpmtrans
  967.  * Bit(s) to control rpmtsRun() operation.
  968.  */
  969. typedef enum rpmtransFlags_e {
  970.     RPMTRANS_FLAG_NONE        = 0,
  971.     RPMTRANS_FLAG_TEST        = (1 <<  0),    /*!< from --test */
  972.     RPMTRANS_FLAG_BUILD_PROBS    = (1 <<  1),    /*!< don't process payload */
  973.     RPMTRANS_FLAG_NOSCRIPTS    = (1 <<  2),    /*!< from --noscripts */
  974.     RPMTRANS_FLAG_JUSTDB    = (1 <<  3),    /*!< from --justdb */
  975.     RPMTRANS_FLAG_NOTRIGGERS    = (1 <<  4),    /*!< from --notriggers */
  976.     RPMTRANS_FLAG_NODOCS    = (1 <<  5),    /*!< from --excludedocs */
  977.     RPMTRANS_FLAG_ALLFILES    = (1 <<  6),    /*!< from --allfiles */
  978. /*@-enummemuse@*/
  979.     RPMTRANS_FLAG_KEEPOBSOLETE    = (1 <<  7),    /*!< @todo Document. */
  980. /*@=enummemuse@*/
  981.     RPMTRANS_FLAG_NOCONTEXTS    = (1 <<  8),    /*!< from --nocontexts */
  982.     RPMTRANS_FLAG_DIRSTASH    = (1 <<  9),    /*!< from --dirstash */
  983.     RPMTRANS_FLAG_REPACKAGE    = (1 << 10),    /*!< from --repackage */
  984.  
  985.     RPMTRANS_FLAG_PKGCOMMIT    = (1 << 11),
  986. /*@-enummemuse@*/
  987.     RPMTRANS_FLAG_PKGUNDO    = (1 << 12),
  988. /*@=enummemuse@*/
  989.     RPMTRANS_FLAG_COMMIT    = (1 << 13),
  990. /*@-enummemuse@*/
  991.     RPMTRANS_FLAG_UNDO        = (1 << 14),
  992. /*@=enummemuse@*/
  993.     RPMTRANS_FLAG_REVERSE    = (1 << 15),
  994.  
  995.     RPMTRANS_FLAG_NOTRIGGERPREIN= (1 << 16),    /*!< from --notriggerprein */
  996.     RPMTRANS_FLAG_NOPRE        = (1 << 17),    /*!< from --nopre */
  997.     RPMTRANS_FLAG_NOPOST    = (1 << 18),    /*!< from --nopost */
  998.     RPMTRANS_FLAG_NOTRIGGERIN    = (1 << 19),    /*!< from --notriggerin */
  999.     RPMTRANS_FLAG_NOTRIGGERUN    = (1 << 20),    /*!< from --notriggerun */
  1000.     RPMTRANS_FLAG_NOPREUN    = (1 << 21),    /*!< from --nopreun */
  1001.     RPMTRANS_FLAG_NOPOSTUN    = (1 << 22),    /*!< from --nopostun */
  1002.     RPMTRANS_FLAG_NOTRIGGERPOSTUN = (1 << 23),    /*!< from --notriggerpostun */
  1003. /*@-enummemuse@*/
  1004.     RPMTRANS_FLAG_NOPAYLOAD    = (1 << 24),
  1005. /*@=enummemuse@*/
  1006.     RPMTRANS_FLAG_APPLYONLY    = (1 << 25),
  1007.  
  1008.     RPMTRANS_FLAG_ANACONDA    = (1 << 26),    /*!< from --anaconda */
  1009.     RPMTRANS_FLAG_NOMD5        = (1 << 27),    /*!< from --nomd5 */
  1010.     RPMTRANS_FLAG_NOSUGGEST    = (1 << 28),    /*!< from --nosuggest */
  1011.     RPMTRANS_FLAG_ADDINDEPS    = (1 << 29),    /*!< from --aid */
  1012.     RPMTRANS_FLAG_NOCONFIGS    = (1 << 30),    /*!< from --noconfigs */
  1013.     RPMTRANS_FLAG_DEPLOOPS    = (1 << 31)    /*!< from --deploops */
  1014. } rpmtransFlags;
  1015.  
  1016. #define    _noTransScripts        \
  1017.   ( RPMTRANS_FLAG_NOPRE |    \
  1018.     RPMTRANS_FLAG_NOPOST |    \
  1019.     RPMTRANS_FLAG_NOPREUN |    \
  1020.     RPMTRANS_FLAG_NOPOSTUN    \
  1021.   )
  1022.  
  1023. #define    _noTransTriggers    \
  1024.   ( RPMTRANS_FLAG_NOTRIGGERPREIN | \
  1025.     RPMTRANS_FLAG_NOTRIGGERIN |    \
  1026.     RPMTRANS_FLAG_NOTRIGGERUN |    \
  1027.     RPMTRANS_FLAG_NOTRIGGERPOSTUN \
  1028.   )
  1029.  
  1030. /** \ingroup rpmtrans
  1031.  * Return copy of rpmlib internal provides.
  1032.  * @retval provNames    address of array of rpmlib internal provide names
  1033.  * @retval provFlags    address of array of rpmlib internal provide flags
  1034.  * @retval provVersions    address of array of rpmlib internal provide versions
  1035.  * @return        no. of entries
  1036.  */
  1037. /*@unused@*/
  1038. int rpmGetRpmlibProvides(/*@null@*/ /*@out@*/ const char *** provNames,
  1039.             /*@null@*/ /*@out@*/ int ** provFlags,
  1040.             /*@null@*/ /*@out@*/ const char *** provVersions)
  1041.     /*@modifies *provNames, *provFlags, *provVersions @*/;
  1042.  
  1043. /** \ingroup rpmtrans
  1044.  * Segmented string compare for version and/or release.
  1045.  *
  1046.  * @param a        1st string
  1047.  * @param b        2nd string
  1048.  * @return        +1 if a is "newer", 0 if equal, -1 if b is "newer"
  1049.  */
  1050. int rpmvercmp(const char * a, const char * b)
  1051.     /*@*/;
  1052.  
  1053. /** \ingroup rpmtrans
  1054.  * Check dependency against internal rpmlib feature provides.
  1055.  * @param key        dependency
  1056.  * @return        1 if dependency overlaps, 0 otherwise
  1057.  */
  1058. int rpmCheckRpmlibProvides(const rpmds key)
  1059.     /*@*/;
  1060.  
  1061. /** \ingroup rpmcli
  1062.  * Display current rpmlib feature provides.
  1063.  * @param fp        output file handle
  1064.  */
  1065. void rpmShowRpmlibProvides(FILE * fp)
  1066.     /*@globals fileSystem @*/
  1067.     /*@modifies *fp, fileSystem @*/;
  1068.  
  1069. /*@}*/
  1070.  
  1071. /**
  1072.  * Return  tag data type from value.
  1073.  * @param tag        tag value
  1074.  * @return        tag data type, RPM_NULL_TYPE on not found.
  1075.  */
  1076. int tagType(int tag)
  1077.     /*@*/;
  1078.  
  1079. /**
  1080.  * Return tag name from value.
  1081.  * @param tag        tag value
  1082.  * @return        tag name, "(unknown)" on not found
  1083.  */
  1084. /*@-redecl@*/
  1085. /*@observer@*/ extern const char *const tagName(int tag)
  1086.     /*@*/;
  1087. /*@=redecl@*/
  1088.  
  1089. /**
  1090.  * Return tag value from name.
  1091.  * @param tagstr    name of tag
  1092.  * @return        tag value, -1 on not found
  1093.  */
  1094. int tagValue(const char * tagstr)
  1095.     /*@*/;
  1096.  
  1097. #define    RPMLEAD_BINARY 0
  1098. #define    RPMLEAD_SOURCE 1
  1099.  
  1100. #define    RPMLEAD_MAGIC0 0xed
  1101. #define    RPMLEAD_MAGIC1 0xab
  1102. #define    RPMLEAD_MAGIC2 0xee
  1103. #define    RPMLEAD_MAGIC3 0xdb
  1104.  
  1105. #define    RPMLEAD_SIZE 96        /*!< Don't rely on sizeof(struct) */
  1106.  
  1107. /** \ingroup lead
  1108.  * The lead data structure.
  1109.  * The lead needs to be 8 byte aligned.
  1110.  * @deprecated The lead (except for signature_type) is legacy.
  1111.  * @todo Don't use any information from lead.
  1112.  */
  1113. struct rpmlead {
  1114.     unsigned char magic[4];
  1115.     unsigned char major;
  1116.     unsigned char minor;
  1117.     short type;
  1118.     short archnum;
  1119.     char name[66];
  1120.     short osnum;
  1121.     short signature_type;    /*!< Signature header type (RPMSIG_HEADERSIG) */
  1122. /*@unused@*/ char reserved[16];    /*!< Pad to 96 bytes -- 8 byte aligned! */
  1123. } ;
  1124.  
  1125. /**
  1126.  * Release storage used by file system usage cache.
  1127.  */
  1128. void freeFilesystems(void)
  1129.     /*@globals internalState@*/
  1130.     /*@modifies internalState@*/;
  1131.  
  1132. /**
  1133.  * Return (cached) file system mount points.
  1134.  * @retval listptr        addess of file system names (or NULL)
  1135.  * @retval num            address of number of file systems (or NULL)
  1136.  * @return            0 on success, 1 on error
  1137.  */
  1138. /*@-incondefs@*/
  1139. int rpmGetFilesystemList( /*@null@*/ /*@out@*/ const char *** listptr,
  1140.         /*@null@*/ /*@out@*/ int * num)
  1141.     /*@globals fileSystem, internalState @*/
  1142.     /*@modifies *listptr, *num, fileSystem, internalState @*/
  1143.     /*@requires maxSet(listptr) >= 0 /\ maxSet(num) >= 0 @*/
  1144.     /*@ensures maxRead(num) == 0 @*/;
  1145. /*@=incondefs@*/
  1146.  
  1147. /**
  1148.  * Determine per-file system usage for a list of files.
  1149.  * @param fileList        array of absolute file names
  1150.  * @param fssizes        array of file sizes
  1151.  * @param numFiles        number of files in list
  1152.  * @retval usagesPtr        address of per-file system usage array (or NULL)
  1153.  * @param flags            (unused)
  1154.  * @return            0 on success, 1 on error
  1155.  */
  1156. /*@-incondefs@*/
  1157. int rpmGetFilesystemUsage(const char ** fileList, int_32 * fssizes,
  1158.         int numFiles, /*@null@*/ /*@out@*/ uint_32 ** usagesPtr,
  1159.         int flags)
  1160.     /*@globals rpmGlobalMacroContext, h_errno,
  1161.         fileSystem, internalState @*/
  1162.     /*@modifies *usagesPtr, rpmGlobalMacroContext,
  1163.         fileSystem, internalState @*/
  1164.     /*@requires maxSet(fileList) >= 0 /\ maxSet(fssizes) == 0
  1165.         /\ maxSet(usagesPtr) >= 0 @*/
  1166.     /*@ensures maxRead(usagesPtr) == 0 @*/;
  1167. /*@=incondefs@*/
  1168.  
  1169. /* ==================================================================== */
  1170. /** \name RPMEIU */
  1171. /*@{*/
  1172. /* --- install/upgrade/erase modes */
  1173.  
  1174. /** \ingroup rpmcli
  1175.  * Bit(s) to control rpmInstall() operation.
  1176.  * @todo Move to rpmcli.h
  1177.  */
  1178. typedef enum rpmInstallInterfaceFlags_e {
  1179.     INSTALL_NONE    = 0,
  1180.     INSTALL_PERCENT    = (1 << 0),    /*!< from --percent */
  1181.     INSTALL_HASH    = (1 << 1),    /*!< from --hash */
  1182.     INSTALL_NODEPS    = (1 << 2),    /*!< from --nodeps */
  1183.     INSTALL_NOORDER    = (1 << 3),    /*!< from --noorder */
  1184.     INSTALL_LABEL    = (1 << 4),    /*!< from --verbose (notify) */
  1185.     INSTALL_UPGRADE    = (1 << 5),    /*!< from --upgrade */
  1186.     INSTALL_FRESHEN    = (1 << 6),    /*!< from --freshen */
  1187.     INSTALL_INSTALL    = (1 << 7),    /*!< from --install */
  1188.     INSTALL_ERASE    = (1 << 8)    /*!< from --erase */
  1189. } rpmInstallInterfaceFlags;
  1190.  
  1191. /** \ingroup rpmcli
  1192.  * Bit(s) to control rpmErase() operation.
  1193.  */
  1194. typedef enum rpmEraseInterfaceFlags_e {
  1195.     UNINSTALL_NONE    = 0,
  1196.     UNINSTALL_NODEPS    = (1 << 0),    /*!< from --nodeps */
  1197.     UNINSTALL_ALLMATCHES= (1 << 1)    /*!< from --allmatches */
  1198. } rpmEraseInterfaceFlags;
  1199.  
  1200. /*@}*/
  1201. /* ==================================================================== */
  1202. /** \name RPMK */
  1203. /*@{*/
  1204.  
  1205. /** \ingroup signature
  1206.  * Tags found in signature header from package.
  1207.  */
  1208. enum rpmtagSignature {
  1209.     RPMSIGTAG_SIZE    = 1000,    /*!< internal Header+Payload size in bytes. */
  1210.     RPMSIGTAG_LEMD5_1    = 1001,    /*!< internal Broken MD5, take 1 @deprecated legacy. */
  1211.     RPMSIGTAG_PGP    = 1002,    /*!< internal PGP 2.6.3 signature. */
  1212.     RPMSIGTAG_LEMD5_2    = 1003,    /*!< internal Broken MD5, take 2 @deprecated legacy. */
  1213.     RPMSIGTAG_MD5    = 1004,    /*!< internal MD5 signature. */
  1214.     RPMSIGTAG_GPG    = 1005, /*!< internal GnuPG signature. */
  1215.     RPMSIGTAG_PGP5    = 1006,    /*!< internal PGP5 signature @deprecated legacy. */
  1216.     RPMSIGTAG_PAYLOADSIZE = 1007,/*!< internal uncompressed payload size in bytes. */
  1217.     RPMSIGTAG_BADSHA1_1    = RPMTAG_BADSHA1_1,    /*!< internal Broken SHA1, take 1. */
  1218.     RPMSIGTAG_BADSHA1_2    = RPMTAG_BADSHA1_2,    /*!< internal Broken SHA1, take 2. */
  1219.     RPMSIGTAG_SHA1    = RPMTAG_SHA1HEADER,    /*!< internal sha1 header digest. */
  1220.     RPMSIGTAG_DSA    = RPMTAG_DSAHEADER,    /*!< internal DSA header signature. */
  1221.     RPMSIGTAG_RSA    = RPMTAG_RSAHEADER    /*!< internal RSA header signature. */
  1222. };
  1223.  
  1224. /** \ingroup signature
  1225.  * Verify a signature from a package.
  1226.  *
  1227.  * This needs the following variables from the transaction set:
  1228.  *    - ts->sigtag    type of signature
  1229.  *    - ts->sig    signature itself (from signature header)
  1230.  *    - ts->siglen    no. of bytes in signature
  1231.  *    - ts->dig    signature/pubkey parameters (malloc'd workspace)
  1232.  *
  1233.  * @param ts        transaction set
  1234.  * @retval result    detailed text result of signature verification
  1235.  * @return        result of signature verification
  1236.  */
  1237. rpmRC rpmVerifySignature(const rpmts ts,
  1238.         /*@out@*/ char * result)
  1239.     /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
  1240.     /*@modifies ts, *result, rpmGlobalMacroContext,
  1241.         fileSystem, internalState @*/;
  1242.  
  1243. /** \ingroup signature
  1244.  * Destroy signature header from package.
  1245.  * @param h        signature header
  1246.  * @return        NULL always
  1247.  */
  1248. /*@null@*/ Header rpmFreeSignature(/*@null@*/ /*@killref@*/ Header h)
  1249.     /*@modifies h @*/;
  1250.  
  1251. /*@}*/
  1252.  
  1253. #ifdef __cplusplus
  1254. }
  1255. #endif
  1256.  
  1257. #endif    /* H_RPMLIB */
  1258.